package org.shan.hangtian.tp;

/**
 * Created by amanda.shan on 2020/11/6.
 */
public enum RunMode {

    MODE_1(1, "缓解模式"), MODE_2(0, "助眠模式"), MODE_OTHER(2, "其他模式");

    private int code;

    private String description;

    private RunMode(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static RunMode decode(int code) {
        RunMode[] commands = RunMode.values();
        for (int i = 0; i < commands.length; i++) {
            if (code == commands[i].code) {
                return commands[i];
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return description;
    }
}
